<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="<%=basePath %>/resource/js/common-css-js.js"></script>
<title>大旗科技有限公司</title>
<style>
	body {
		padding: 10px;
	}
	
	.tools {
		width: 100%;
	    background: #f1f1f1;
	    border: 1px solid #CCB;
	    border-bottom: 0px;
	    padding: 0 5px;
	    display: flex;
	}
	
	.tools-item {
		padding: 5px 10px;
	    font-weight: bold;
	    color: #999;
	    cursor: pointer;
	}

	.layui-icon {
		font-size: 15px;
	}
	
	.tools-item:hover {
		color: black;
	}
	
</style>
</head>
<body>

	<div class="tools">
	 	<div class="tools-item tools-item-submit">
	 		<i class="layui-icon layui-icon-upload-circle"></i>   
	 	</div>
	 	<div class="tools-item tools-item-clean">
	 		<i class="layui-icon layui-icon-fonts-clear"></i>   
	 	</div>
	</div>
	 
	<div id="editor">
    </div>
    
    <script type="text/javascript" src="<%=basePath %>/resource/js/wangEditor.min.js"></script>
    <script type="text/javascript">
        var E = window.wangEditor
        var editor = new E('#editor')
        editor.create()
        
        //提交数据
        $(".tools-item-submit").click(function(){
        	//获取到文本的内容
        	var content = editor.txt.html();
        	
        	//发布主题
        	layer.prompt({title:'发布主题'},function(val, index){
        	 	
        		//发送同步ajax请求
        		$.ajax({
        		   url: path + "/notice",
       			   type: "POST",
       			   async: false,
       			   data: { "noticeTheme" : val,"noticeContent" : content},
	       		   beforeSend: function () {
	     			   layerIndex = layer.load(2);
	               },
	               statusCode : {
	            	   200: function(){
	            		   fixedAlert('发布公告成功!',1,true);
	            	   },
	            	   400: function(){
	            		   fixedAlert('发布公告失败!',2);
	            	   },
	            	   500: function(){
	            		   fixedAlert('服务器繁忙!',0);
	            	   }
	               },
	               complete: function(XMLHttpRequest, textStatus){
	            	   layer.close(layerIndex);
	               }
       			});
        		
        	});
        	
        });
        
        //清空内容
        $(".tools-item-clean").click(function(){
        	$("div[contenteditable='true']").children().remove();
        });
    </script>
</body>
</html>